﻿using Doc_XML.Models.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Doc_XML.Controllers
{
    public class SearchAutoController : Controller
    {
        //
        // GET: /SearchAuto/
       
        Model1 db = new Model1();
        public ActionResult Index()
        {
          
            return View();
        }
        public ActionResult searchform()
        {
            return View();
        }
        public ActionResult Search(String keyword="")
        {
            var model = db.Products
                       .Where(m => m.Name.Contains(keyword))
                       .ToList();
            return PartialView(model);
        }
        
        public ActionResult jsonSearchForm()
        {
            return View();
        }
        public ActionResult JsonSearch(String Name ="")
        {
            var model = db.Products
                       .Where(p => p.Name.Contains(Name))
                       .Select(p => new { p.Name, p.UnitPrice });
            return Json(model, JsonRequestBehavior.AllowGet);
        }
      
        

	}
}